{% extends 'home.html' %}


{% block content %}

    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">编辑图书</h3>
        </div>
        <div class="panel-body">
            <form action="" class="form-group" method="post">
                <div>
                    title: <input type="text" name="title" class="form-control" value="{{ book_obj.title }}">
                </div>
                <div>
                    price: <input type="text" name="price" class="form-control" value="{{ book_obj.price }}">
                </div>
                <div>
                    date: <input type='date' name="date" class="form-control"
                                 value="{{ book_obj.publish_date|date:'Y-m-d' }}">
                </div>
                <div>
                    publish：<select name="publish" id="" class="form-control">
                    {% for publish_obj in publish_objs %}
                        {% if book_obj.publish == publish_obj %}
                            <option value="{{ publish_obj.pk }}" selected>{{ publish_obj.name }}</option>
                        {% else %}
                            <option value="{{ publish_obj.pk }}">{{ publish_obj.name }}</option>
                        {% endif %}

                    {% endfor %}
                </select>
                </div>
                <div>
                    authors：<select name="authors" id="" multiple class="form-control">
                    {% for author_obj in authors %}
                        {% if author_obj in book_obj.authors.all %}
                            <option value="{{ author_obj.pk }}" selected>{{ author_obj.name }}</option>
                        {% else %}
                            <option value="{{ author_obj.pk }}">{{ author_obj.name }}</option>
                        {% endif %}

                    {% endfor %}
                </select>
                </div>
                <input class="btn btn-primary btn-block" type="submit" value="Submit">
            </form>
        </div>
    </div>
{% endblock %}